package com.teach;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateTest {

	public static void main(String[] args) {
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
		
		Date d1 = new Date();
		System.out.println(d1);
		System.out.println(format.format(d1));
		
		Date d2 = new Date(0);
		System.out.println(format.format(d2));
//		d2.getTimezoneOffset();//时区,废弃的方法
		
		System.out.println(d1.after(d2));
		System.out.println(d1.getTime()>d2.getTime());
		System.out.println(d1.before(d2));
		
		Date d3 = (Date)d1.clone();
		d3.setTime(d3.getTime()+1000*60*60);//一个小时以后
		System.out.println(format.format(d1));
		System.out.println(format.format(d3));
		
		System.out.println(d1.equals(d3));
		
		//下面的方法全部都是废弃的,不要使用
		System.out.println(d1.getYear());
		System.out.println(d1.getMonth());//月份+1
		System.out.println(d1.getDay());//0-6
		d1.setMonth(4);
		
		
	}
}
